//
//  HomeFlowLayout.swift
//  ParkManage
//
//  Created by Jalon on 9/21/20.
//  Copyright © 2020 diligrp. All rights reserved.
//

import UIKit

class HomeFlowLayout: UICollectionViewFlowLayout {
    
    var kItemW: CGFloat {
        didSet {
            if Configs.Dimensions.screenWidth < 375 {
                kItemW = 100
            }
        }
    }
    
    var kItemH: CGFloat {
        didSet {
            if Configs.Dimensions.screenWidth < 375 {
                kItemH = 90
            }
        }
    }
    
    /// 每行最大列数
    let kMaxCol: CGFloat = 2
    /// 行间距
    var kMargin: CGFloat {
        (Configs.Dimensions.screenWidth - (kItemW * kMaxCol)) / (kMaxCol + 1)
    }

    override init() {
        kItemW = 150
        kItemH = 150
        super.init()
        scrollDirection = .vertical
        itemSize = CGSize(width: kItemW, height: kItemH)
        minimumLineSpacing = kMargin
        minimumInteritemSpacing = 12
        sectionInset = UIEdgeInsets(top: 10, left: kMargin, bottom: 0, right: kMargin)
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

}
